package com.suny.sort_thread;

/**
 * @author Sunny
 * @date 2020/3/9
 */
public class ThreadJoinTest {
    public static void main(String[] args) throws InterruptedException {
        Thread thread1 = new Thread(() -> {
            System.out.println(Thread.currentThread().getName() + ": 执行");
        }, "Thread-1");

        Thread thread2 = new Thread(() -> {
            System.out.println(Thread.currentThread().getName() + ": 执行");
        }, "Thread-2");

        thread1.start();
        // 让主线程等待线程1执行完成
        thread1.join();

        thread2.start();
        // 让主线程等待线程2执行完成
        thread2.join();

        System.out.println("主线程执行完毕");
    }
}
